<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateGoodsOrderDetailTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create ('goods_order_detail', function (Blueprint $table) {
            $table->engine = 'InnoDB';
            $table->uuid ('id')->primary ('id');//订单明细表ID
            $table->uuid ('goods_id');//商品ID
            $table->uuid ('sub_order_id');//子订单ID
            $table->unsignedDecimal ('goods_price', 11, 2);//商品价格
            $table->unsignedDecimal ('market_price', 11, 2);//市场价格
            $table->integer ('buy_number');//购买数量
            $table->timestamps ();
            $table->foreign ('sub_order_id')->references ('id')->on ('goods_order_sub')->onDelete ('cascade');//子订单外键
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists ('goods_order_detail');
    }
}
